/*
 * Copyright (C) 2022 KylinSoft Co., Ltd.
 *
 * This program is free software: you can redistribute it and/or modify it under
 * the terms of the GNU General Public License as published by the Free Software
 * Foundation, either version 3 of the License, or (at your option) any later
 * version.
 *
 * This program is distributed in the hope that it will be useful, but WITHOUT
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
 * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License along with
 * this program. If not, see <https://www.gnu.org/licenses/>.
 */

#ifndef SETTINGS_H
#define SETTINGS_H

#include <QObject>
#include <QSettings>

class Settings : public QSettings
{
    Q_OBJECT
public:
    Settings(const QString &fileName, Format format, const QString group, QObject *parent = nullptr);
    ~Settings();

    QString group() const;
    void setGroup(const QString &group);

    QVariant value(const QString &key, const QVariant &defaultValue = QVariant());
    void setValue(const QString &key, const QVariant &value);

    void remove(const QString &key);
    bool contains(const QString &key);

    QList<QMap<QString, QVariant> > readArray(const QString &prefix);
    void setArray(const QString &prefix, const QList<QMap<QString, QVariant> > &hashList);

    void clear();

    QStringList allKeys();
    QStringList childGroups();

signals:
    void settingsChanged();

protected:
    bool event(QEvent *event);

private:
    QString m_group;

};

#endif // SETTINGS_H
